﻿using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyExtension.Redis
{
    [Description("普通缓存考虑直接使用ICaching,如果要使用Redis队列等还是使用此类")]
    public interface IRedisBasketRepository
    {
        /// <summary>
        /// 根据key获取缓存值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<string>GetValue(string key);

        /// <summary>
        /// 获取值并序列化
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<TEntity>Get<TEntity>(string key);
        /// <summary>
        /// 设置缓存值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="cacheTime"></param>
        /// <returns></returns>
        Task Set(string key,object value,TimeSpan cacheTime);
        /// <summary>
        /// 判断是否存在
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<bool>Exists(string key);
        /// <summary>
        /// 移除某一个缓存值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task Remove(string key);

        /// <summary>
        /// 全部清除
        /// </summary>
        /// <returns></returns>
        Task Clear();

        //Task<RedisValue[]> ListRedisAsync(string key);

        //Task<long>ListLeftPushAsync(string key,string value,int db=-1);

        //Task<long> ListRightPushAsync(string key, string value, int db = -1);
        //Task<long> ListRightPushAsync(string key, IEnumerable<string> value, int db = -1);
        

    }
}
